package cn.edu.sdjzu.xg.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebFilter(filterName = "Filter 00", urlPatterns = {"/*"})
public class Filter00 implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest) request;
        HttpServletResponse res = (HttpServletResponse) response;
        req.setCharacterEncoding("UTF-8");
        res.setContentType("text/html;charset=UTF-8");
        String path = req.getRequestURI();
        System.out.println("请求的资源为：" + path);
        System.out.println("Filter 00 begins");

        chain.doFilter(request, response);
        System.out.println("Filter 00 ends");
    }

    @Override
    public void destroy() {

    }
}
